from pydantic_settings import BaseSettings
from pydantic import Field
import os

class Settings(BaseSettings):
    """应用配置类"""
    
    # 通义千问API配置
    dashscope_api_key: str = Field(..., env="DASHSCOPE_API_KEY")
    
    # 服务器配置
    host: str = Field(default="0.0.0.0", env="HOST")
    port: int = Field(default=9001, env="PORT")
    debug: bool = Field(default=True, env="DEBUG")
    
    # 音频文件配置
    audio_dir: str = Field(default="./audio_files", env="AUDIO_DIR")
    
    # CORS配置
    cors_origins: list = Field(default=["*"])
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"

# 创建全局配置实例
settings = Settings()

# 确保音频目录存在
os.makedirs(settings.audio_dir, exist_ok=True)